﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace 桌面视频录制
{
    [Serializable]
    public class DrawRectangleWithFill : DrawRectangle
    {
        public DrawRectangleWithFill(Point leftUpPoint)
        {
            this.leftUpPoint = leftUpPoint;
            this.rightUpPoint = new Point(leftUpPoint.X, leftUpPoint.Y);
            this.leftDownPoint = new Point(leftUpPoint.X, leftUpPoint.Y);
            this.rightDownPoint = new Point(leftUpPoint.X, leftUpPoint.Y);
        }
        public override void Draw(Graphics g)
        {
            Matrix matrix = new Matrix();
            matrix.RotateAt((float)(angle * 180 / Math.PI), leftUpPoint);
            Matrix matrixBrush = new Matrix();
            matrixBrush.RotateAt((float)(-angle * 180 / Math.PI), leftUpPoint);
            Brush brush = this.DrawBrush.GetBrush(matrixBrush);
            g.Transform = matrix;
            g.FillRectangle(brush, leftUpPoint.X, leftUpPoint.Y, width, height);
            g.ResetTransform();
            matrixBrush.Dispose();
            matrix.Dispose();
            brush.Dispose();
        }
        public override string ToString()
        {
            string printMsg = "[实矩(" + this.leftUpPoint.X + "," + this.leftUpPoint.Y + ")]->[ID:" + this.Id + "]";
            return printMsg;
        }
        public override string GetDrawObjectMsg()
        {
            string drawObjectMsg = "实矩->起始位置(" + this.leftUpPoint.X + "," + this.leftUpPoint.Y + "),宽高(" + this.width + "," + this.height + "),偏移角度:" + ((int)(angle * 180 / Math.PI)) + "°";
            return drawObjectMsg;
        }
    }
}
